package com.marlon.springboot.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.marlon.springboot.mybatisplus.entity.User;
import com.marlon.springboot.mybatisplus.mapper.IUserMapper;
import com.marlon.springboot.mybatisplus.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author marlon
 * @create 2023-11-18 14:03
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserMapper userMapper;

    @Override
    public List<User> queryAll() {
        return userMapper.selectList(new QueryWrapper<>());
    }

    @Override
    public User findById(String id) {
        return userMapper.selectById(id);
    }

    @Override
    public int save(User user) {
//        user.setId(IdUtil.randomUUID());
        return userMapper.insert(user);
    }

    @Override
    public int updateById(User user) {
        return userMapper.updateById(user);
    }

    @Override
    public int deleteById(String id) {
        return userMapper.deleteById(id);
    }
}
